package com.duckygo.towerdefense.game.sprites;

import com.duckygo.towerdefense.game.scenes.TowerDefenseScene;

public class UnitHealth extends Sprite2D {

	private Unit unit;
	
	public int health;

	private int startHealth;
	
	public UnitHealth(Unit unit, int startHealth) {
		this.unit = unit;
		this.health = this.startHealth = startHealth;
		this.texture = TowerDefenseScene.HEALTH_TEX;
		
		this.visible = false;
		this.y = - 32;
		
		this.width = 32;
		this.height = 16;
		
		scaleY = 0.25f;
	}
	
	
	public boolean hurt(int health) {
		visible = true;
		this.health -= health;
		
		width = 64 * this.health / startHealth;
		
		return (this.health <= 0);
	}
}
